#include "StdAfx.h"
#include "util.h"

const char *Database::toStr(const char *str)
{
	return str == NULL ? "" : str;
}

unsigned int Database::toUint(const char *str)
{
	return atoi(toStr(str));
}

unsigned int Database::toUint(const std::string &str)
{
	return toUint(str.c_str());
}

std::string Database::toStr(unsigned int v)
{
	char buf[20] = {0}; 

	sprintf_s(buf, "%d", v);

	return buf;
}

std::string Database::toTime(const SYSTEMTIME &st)
{
	char buf[30] = {0};
	sprintf_s(buf, "%4d-%02d-%02d %02d:%02d:%02d", 
		st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

	return buf;
}